/*
* serial.h - openwii serial header
* Copyright 2006-2008 OpenWii (admin@openwii.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* Version 2.4 by Andii
*/

#ifndef SERIAL_H_
#define SERIAL_H_

enum SerialCommands
{
	CMD_READ8	= 0x1f,
	CMD_READ16	= 0x2f,
	CMD_WRITE8	= 0x1e,
	CMD_WRITE16	= 0x2e,

	CMD_WRITE	= 0xfe,
	CMD_READ	= 0xff
};

#define SERIAL_CMD_SIZE 10

// how many uS to wait between clocking out/in data
#define SERCLKDLY 0x8

// global return value from SerialRequest() save code size
extern uint16_t ret_word;

void Sync();
uint8_t SerialRequest(uint8_t command, uint32_t offset, uint16_t data);
void SendBlock(uint32_t offset, const uint8_t* buff, uint16_t size);

#endif	// SERIAL_H_
